home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lantools
/
blueprnt
/
misc.mod
< prev
next >
Wrap
Text File
|
1989-11-28
|
5KB
|
223 lines
;*************************************************************
;* Miscellaneous Subroutine Module (MISC.MOD) *
;* by Craig Chaiken *
;* November 28, 1989 *
;* *
;* Function: General Purpose Subroutines and Macros *
;*************************************************************
ticks_low dw ?
ticks_high dw ?
cmz macro ;*** Complement Z Flag ***
lahf
xor ah,64
sahf
endm
stz macro ;*** Set Carry Flag ***
cmp al,al
endm
clz macro ;*** Clear Carry Flag ***
lahf
and ah,255-64
sahf
endm
pushall macro ;*** Save All Registers ***
pushf
push es
push ds
push bp
push di
push si
push dx
push cx
push bx
push ax
endm
popall macro ;*** Restore All Registers ***
pop ax
pop bx
pop cx
pop dx
pop si
pop di
pop bp
pop ds
pop es
popf
endm
get_opt proc near ;*** CX = Next Integer after DS:SI of form /nnnnn ***
xor cx,cx
call wslash
cmp al,1fh
jb get_o1
call get_dec
get_o1: ret
get_opt endp
get_dec proc near ;*** CX = ASCII Decimal Number at DS:SI ***
push ax ;*** or ASCII HEX Preceeded by '$' ***
pushf
xor cx,cx
xor ah,ah
cmp byte ptr [si],'$'
jz get_hex
get_d1: mov al,[si]
cmp al,'0'
jb get_d2
cmp al,'9'
ja get_d2
sub al,30h
call cx10
add cx,ax
inc si
jmp get_d1
get_d2: popf
pop ax
ret
get_hex:
inc si
get_d3: mov al,[si]
cmp al,'0'
jc get_d2
cmp al,'9'+1
jc get_d4
and al,255-32 ;convert to uppercase
cmp al,'A'
jc get_d2
cmp al,'F'
ja get_d2
sub al,7
get_d4: sub al,'0'
add cx,cx
add cx,cx
add cx,cx
add cx,cx
add cx,ax
inc si
jmp get_d3
get_dec endp
get_ticks proc near ;DX=MSW of ticks since boot time
push es ;CX=LSW of ticks since boot time
push di
push ax
mov ah,1
int 16h
mov ax,40h
mov es,ax
mov di,6ch
mov cx,es:[di]
mov dx,es:[di+2]
pop ax
pop di
pop es
ret
get_ticks endp
wait_a_sec proc near ;pause approximately one second
push cx
push dx
call get_ticks
mov cs:ticks_low,cx
mov cs:ticks_high,dx
wait_1: call get_ticks
sub cx,cs:ticks_low
sbb dx,cs:ticks_high
cmp cx,19
jc wait_1
pop dx
pop cx
ret
wait_a_sec endp
cx10 proc near ;*** Multiply CX by 10 ***
push bx
add cx,cx
mov bx,cx
add cx,cx
add cx,cx
add cx,bx
pop bx
ret
cx10 endp
wslash proc near ;al=first character after slash
mov al,[si] ; or control character if no slash
inc si
cmp al,'/'
jz wslas1
cmp al,1fh
ja wslash
ret
wslas1: mov al,[si]
ret
wslash endp
sitodi proc near ;*** Move CX bytes from DS:SI to DS:DI ***
pushf
push es
push ds
pop es
cld
shr cx,1
rep movsw
rcl cx,1
rep movsb
pop es
popf
ret
sitodi endp
essitodi proc near ;*** Move CX bytes from ES:SI to DS:DI ***
pushf
push es
push ds
push es ;swap ES and DS
push ds
pop es
pop ds
cld
shr cx,1
rep movsw
rcl cx,1
rep movsb
pop ds
pop es
popf
ret
essitodi endp
sitoesdi proc near ;*** Move CX bytes from DS:SI to ES:DI ***
pushf
cld
shr cx,1
rep movsw
rcl cx,1
rep movsb
popf
ret
sitoesdi endp
uppercase proc near ;*** Convert Byte in AL to Uppercase ***
cmp al,'a'
jb upper1
cmp al,'z'
ja upper1
and al,255-32
upper1: ret
uppercase endp
;*************************************************************
;* End of Miscellaneous Subroutine Module *
;*************************************************************